enable deterministic in bnb 4 bit tests#11738
Conversation
Signed-off-by: jiqing-feng <jiqing.feng@intel.com>
|
Hi @sayakpaul , could you please review this PR? Thanks! |
sayakpaul
left a comment
There was a problem hiding this comment.
Should it not be propagated to test_mixed_int8.py as well?
Right, fixed. |
|
Hold on for a while, need to recheck if it works. |
|
Hi @sayakpaul . I have verified this PR on both |
Signed-off-by: jiqing-feng <jiqing.feng@intel.com>
| seed = 0 | ||
|
|
||
| @classmethod | ||
| def setUpClass(cls): |
There was a problem hiding this comment.
The @classmethod method setUpClass() is automatically called once per test class, before any test methods run.
There was a problem hiding this comment.
We have this:
diffusers/tests/quantization/bnb/test_4bit.py
Line 124 in 7fc53b5
There was a problem hiding this comment.
setUp will be called before each test module but setUpClass will be called only once before all test modules in a test class. For torch.use_deterministic_algorithms(True), we only need called once so it's better in the setUpClass.
The motivation is that I can pass all tests when running
pytest -rA tests/quantization/bnb/test_4bit.py, but failed onpytest -rA tests/quantization/bnb/test_4bit.py::ExtendedSerializationTest. That's because running all tests will trigger torch.use_deterministic_algorithms(True), and it will have impact on all the following tests. So the correct way should be calling this function at the setup stage.